package com.example.androidcompletesec.fragment;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.example.androidcompletesec.R;

public class FragmentEx extends Activity {
	final static String TAG = "Life Cycle";
	final static String ACT_TAG="Activity";
	final static String FRG_TAG="		Fragment";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Log.d(TAG, ACT_TAG + "onCreate()");
		super.onCreate(savedInstanceState);
		setContentView(R.layout.fragmentex);
	}
	
	@Override
	protected void onStart() {
		Log.d(TAG, ACT_TAG + "onCreate()");
		super.onStart();
	}

	@Override
	protected void onResume() {
		Log.d(TAG, ACT_TAG + "onResume()");
		super.onResume();
	}

	@Override
	protected void onPause() {
		Log.d(TAG, ACT_TAG + "onPause()");
		super.onPause();
	}

	@Override
	protected void onStop() {
		Log.d(TAG, ACT_TAG + "onStop()");
		super.onStop();
	}

	@Override
	protected void onDestroy() {
		Log.d(TAG, ACT_TAG + "onDestroy()");
		super.onDestroy();
	}

	public static class CounterFragment extends Fragment{

		@Override
		public void onAttach(Activity activity) {
			Log.d(TAG, FRG_TAG + "onAttach()");
			super.onAttach(activity);
		}

		@Override
		public void onCreate(Bundle savedInstanceState) {
			Log.d(TAG, FRG_TAG + "onCreate()");
			super.onCreate(savedInstanceState);
			

		}

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			Log.d(TAG, FRG_TAG + "onCreateView()");
			super.onCreateView(inflater, container, savedInstanceState);
			
			View root = inflater.inflate(R.layout.counterfrg, null);
			Button btnIncrease = (Button) root.findViewById(R.id.btnincrease);
			final TextView tv = (TextView) root.findViewById(R.id.textView1);
			btnIncrease.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					int count = Integer.parseInt(tv.getText().toString());
					tv.setText(Integer.toString(count+1));
				}
			});
			return root;
		}

		@Override
		public void onActivityCreated(Bundle savedInstanceState) {
			Log.d(TAG, FRG_TAG + "onActivityCreated()");
			super.onActivityCreated(savedInstanceState);
		}
		
		@Override
		public void onStart() {
			Log.d(TAG, FRG_TAG + "onStart()");
			super.onStart();
		}

		@Override
		public void onResume() {
			Log.d(TAG, FRG_TAG + "onResume()");
			super.onResume();
		}

		@Override
		public void onPause() {
			Log.d(TAG, FRG_TAG + "onPause()");
			super.onPause();
		}

		@Override
		public void onStop() {
			Log.d(TAG, FRG_TAG + "onStop()");
			super.onStop();
		}

		@Override
		public void onDestroy() {
			Log.d(TAG, FRG_TAG + "onDestroy()");
			super.onDestroy();
		}

		@Override
		public void onDetach() {
			Log.d(TAG, FRG_TAG + "onDetach()");
			super.onDetach();
		}

		
	}
}
